package cn.buk.tms.eotms.report.dto;

import cn.buk.tms.eotms.entity.BillFlightRefundTicket;
import cn.buk.tms.eotms.entity.FlightInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Date;


/**
 * 输出报表时的机票内容：融合了出票，退票，改签的信息，方便在页面暂时的时候，
 * 尽量将同一张票号的退票、改签放在上下挨着的
 */
public class ReportTicketRefundDto extends ReportTicketDto{

	public static ReportTicketRefundDto createReportRefundDto(BillFlightRefundTicket refundTicket) {
		ReportTicketRefundDto dto = new ReportTicketRefundDto();

		BeanUtils.copyProperties(refundTicket, dto);
		dto.setTicketType(1);

		dto.setAmount(-refundTicket.getPassengerRefundAmount());
		dto.setPassengerName(refundTicket.getPsgName());

		dto.setSubmitDate(refundTicket.getSubmitDate());
		dto.setPsgRefundDate(refundTicket.getPsgRefundDate());

		dto.setDetails(new ArrayList<>());

		for(FlightInfo fltInfo: refundTicket.getFlights()) {
			ReportTicketDetailDto detailDto = ReportTicketDetailDto.createByFlightInfo(fltInfo);

			dto.getDetails().add(detailDto);
		}

		return dto;
	}

	/**
	 * 退票日期：退票提交日期
	 */
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date submitDate;

	/**
	 * 实退客户日期
	 */
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date psgRefundDate;

	public Date getSubmitDate() {
		return submitDate;
	}

	public void setSubmitDate(Date submitDate) {
		this.submitDate = submitDate;
	}

	public Date getPsgRefundDate() {
		return psgRefundDate;
	}

	public void setPsgRefundDate(Date psgRefundDate) {
		this.psgRefundDate = psgRefundDate;
	}

}
